#include <avr/io.h>
#include <util/delay.h>
#include "pwm.h"

void pwm_init(void)
{
  TCCR0|=(1<<WGM00)|(1<<WGM01)|(1<<COM01)|(1<<CS00)|(1<<CS02);
  DDRB|=(1<<PB3);
}


void pwm_setduty(unsigned char duty)
{
   OCR0=duty;
}

void pwm_off(void)
{
	 TCCR0 &= 0xCF;
}

void input_capture_init(void)
{
	TCCR1B |= (1<<CS10)|(1<<CS10);// (1<<ICNC1)|(1<<ICES1)|(1<<CS10);//|(1<<CS10);
}

unsigned int read_icr(void)
{
	unsigned char i;
	i=ICR1L;
	return ICR1H|(ICR1L>>8);
}
